# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=tqdm
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=4.51.0
pkgrel=1
pkgdesc='Fast, Extensible Progress Meter (mingw-w64)'
arch=('any')
url="https://github.com/tqdm/tqdm"
license=('MIT' 'MPL')
depends=("${MINGW_PACKAGE_PREFIX}-python")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-nose" "${MINGW_PACKAGE_PREFIX}-python-coverage" "${MINGW_PACKAGE_PREFIX}-python-flake8")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-$pkgver.tar.gz::https://github.com/tqdm/tqdm/archive/v$pkgver.tar.gz")
sha256sums=('9701eebabd62664bc4a8d451cf0d65eae44a93593969492f4ee602a60725afd5')

prepare() {  
  cd "$srcdir"
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py egg_info
  PYTHONPATH="$PWD" ${MINGW_PREFIX}/bin/nosetests --ignore-files="tests_perf\.py" || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENCE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENCE"
}
